# -*- coding = utf-8 -*-
# @Time : 2023/6/9 15:05
# @Author : GHHHHHHHHH
# @File : ftp_util.py
# @Software : PyCharm
import ftplib
from config import FTPConfig

class FTP:
    def __init__(self):
        self.ftp = ftplib.FTP()
        self.ftp.connect(FTPConfig.FTP_IP, FTPConfig.FTP_PORT)
        self.ftp.login(FTPConfig.USERNAME, FTPConfig.PASSWORD)
        self.ftp.set_pasv(False)

    def upload(self, image_file, filename):
        self.ftp.storbinary(f'STOR {filename}', image_file)

    def close(self):
        self.ftp.quit()